#include<bits/stdc++.h>

using namespace std;
const int N = 1000;

double f(double x) {
    return 1;
}

double g(double x) {
    return x;
}

double h(double x) {
    return x * x;
}

double integrate(double(*func)(double), double a, double b) {
    double dx = (b - a) / N;
    double tot = 0;
    for (int i = 0; i < N; i++) {
        double h1 = func(a + i * dx);
        double h2 = func(a + (i + 1) * dx);

        tot += (h1 + h2) * dx / 2;
    }
    return tot;
}

int main() {
    double a = 0, b = 1;

    cout << integrate(f, a, b) << endl;
    cout << integrate(g, a, b) << endl;
    cout << integrate(h, a, b) << endl;
    cout << integrate(sqrt, a, b) << endl;
    cout << integrate(sin, a, b) << endl;

}
